inline int MakeInt(const tstring& text)
{
	tstringstream buffer; int output;
	buffer << text;
	buffer >> output;
	return output;
}
inline float MakeFloat(const tstring& text)
{
	tstringstream buffer; float output;
	buffer << text;
	buffer >> output;
	return output;
}
inline long MakeUINT(const tstring& text)
{
	tstringstream buffer; UINT output;
	buffer << text;
	buffer >> output;
	return output;
}
inline tstring MakeString(int getal)
{
	tstringstream buffer;
	buffer << getal;
	return buffer.str();
}
inline tstring MakeString(float getal)
{
	tstringstream buffer;
	buffer << getal;
	return buffer.str();
}
inline tstring MakeString(__int64 getal)
{
	tstringstream buffer;
	buffer << getal;
	return buffer.str();
}
inline __int64 MakeBigInt(const tstring& text)
{
	tstringstream buffer;
	buffer << text;
	__int64 getal;
	buffer >> getal;
	return getal;
}
inline tstring AddTime(tstring& time1, const tstring& time2)
{
	int year = MakeInt(time1.substr(0,4));
	int month = MakeInt(time1.substr(4,2));
	int day = MakeInt(time1.substr(6,2));
	int hour = MakeInt(time1.substr(8,2));
	int minute = MakeInt(time1.substr(10,2));
	int seconde = MakeInt(time1.substr(12,2));
	int toAdd = MakeInt(time2);
	seconde += toAdd;
	while(seconde >= 60) { minute += 1; seconde -= 60; }
	while(minute >= 60) { hour += 1; minute -= 60; }
	while(hour >= 24) { day += 1; hour -= 24; }
	while(day >= 30) { month += 1; day -= 30; }
	while(month >= 12) { year += 1; month -= 12; }

	tstring output = MakeString(year);
	if(month < 10) output += _T("0");
	output += MakeString(month);
	if(day < 10) output += _T("0");
	output += MakeString(day);
	if(hour < 10) output += _T("0");
	output += MakeString(hour);
	if(minute < 10) output += _T("0");
	output += MakeString(minute);
	if(seconde < 10) output += _T("0");
	output += MakeString(seconde);

	time1 = output; //MakeString(MakeBigInt(time1) + MakeBigInt(time2));
	return output;
}
inline tstring SubtractTime(tstring& time1, const tstring& time2)
{
	int year = MakeInt(time1.substr(0,4));
	int month = MakeInt(time1.substr(4,2));
	int day = MakeInt(time1.substr(6,2));
	int hour = MakeInt(time1.substr(8,2));
	int minute = MakeInt(time1.substr(10,2));
	int seconde = MakeInt(time1.substr(12,2));
	int toAdd = MakeInt(time2);
	seconde -= toAdd;
	while(seconde >= 60) { minute += 1; seconde -= 60; }
	while(minute >= 60) { hour += 1; minute -= 60; }
	while(hour >= 24) { day += 1; hour -= 24; }
	while(day >= 30) { month += 1; day -= 30; }
	while(month >= 12) { year += 1; month -= 12; }

	tstring output = MakeString(year);
	if(month < 10) output += _T("0");
	output += MakeString(month);
	if(day < 10) output += _T("0");
	output += MakeString(day);
	if(hour < 10) output += _T("0");
	output += MakeString(hour);
	if(minute < 10) output += _T("0");
	output += MakeString(minute);
	if(seconde < 10) output += _T("0");
	output += MakeString(seconde);

	time1 = output; //MakeString(MakeBigInt(time1) + MakeBigInt(time2));
	return output;
}

inline int GetDiff(const tstring& time1, const tstring& time2)
{
	__int64 a, b;
	a = (MakeInt(time1.substr(0,4)) * (3600*24*355) + MakeInt(time1.substr(4,2)) * (3600*24*7*30) + MakeInt(time1.substr(6,2)) * (3600*24) +
		MakeInt(time1.substr(8,2)) * (3600) + MakeInt(time1.substr(10,2)) * 60 + MakeInt(time1.substr(12,2)));
	b = (MakeInt(time2.substr(0,4)) * (3600*24*355) + MakeInt(time2.substr(4,2)) * (3600*24*7*30) + MakeInt(time2.substr(6,2)) * (3600*24) +
		MakeInt(time2.substr(8,2)) * (3600) + MakeInt(time2.substr(10,2)) * 60 + MakeInt(time2.substr(12,2)));
	int diff = (int)(a-b);
	return diff;
}

inline tstring MakeTime(int time)
{
	int uren, minuten, seconden;
	uren = time / 3600;
	minuten = (time / 60) - (uren * 60);
	seconden = time - (minuten * 60) - (uren * 3600);
	tstringstream buffer;
	if(uren < 10) buffer << _T("0");
	buffer << uren << _T(":");
	if(minuten < 10) buffer << _T("0");
	buffer << minuten << _T(":");
	if(seconden < 10) buffer << _T("0");
	buffer << seconden;
	return buffer.str();
}